class Spring implements Constraint{
  
  private Sphere s1;
  private float distancia;
  
 public Spring(Sphere s1){
  
   this.s1=s1;
   
   PVector v1 = s1.getVector();
   
   distancia = 0;
  
 } 
 
 public boolean apply(){
   
   PVector v1 = s1.getVector();
   PVector v2 = new PVector(mouseX,mouseY,0);
   
   float dx = v2.x-v1.x;
   float dy = v2.y-v1.y;
   float dz = v2.z-v1.z;
   
   float dista = v1.dist(v2);
   float dista2 =0.5*(dista)/dista;
   dx*=dista2;
   dy*=dista2;
   dz*=dista2;
   
   v1.x+=dx;
   v1.y+=dy;
   v1.z+=dz;
   
   
   return true;
 }
 
 public void draw(){
   PVector v1 = s1.getVector();
   //line(v1.x,v1.y,v1.z,mouseX,mouseY,0);
 }
  
}
